//
//  DbManager.h
//  AppFinance
//
//  Created by wei on 12-6-11.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "FMDatabase.h"

@interface AFDbManager : NSObject
{
    FMDatabase *db;
}

-(void) initDb;
-(void) openDb;
-(void) createTable;

#pragma mark - Table UserSelf
-(BOOL) insertDataWithExCode:(NSString*)_exCode code:(NSString*)_code;
-(BOOL) deleteDataWithCode:(NSString*)_code;
-(void) deleteAllData;

-(NSString*) selectKindKeyWithCode:(NSString*)_code;
    
-(BOOL) isExistCode:(NSString*)_code;
-(NSMutableArray*) selectAllData;
-(int) userSelfTableCount;


#pragma mark - Table BikaSelf
-(BOOL) insertBikaDataWithExCode:(NSString*)_exCode code:(NSString*)_code;
-(BOOL) deleteBikaDataWithCode:(NSString*)_code;
-(void) deleteAllBikaData;

-(NSString*) selectBikaKindKeyWithCode:(NSString*)_code;

-(BOOL) isExistBikaCode:(NSString*)_code;
-(NSMutableArray*) selectAllBikaData;
-(int) BikaSelfTableCount;

#pragma mark - Table NewsCollection
- (BOOL) newsCollectionInsertDataWithColumn:(NSString*)_column newsId:(NSString*)_newsId title:(NSString*)_title
                                       time:(NSString*)_time imageUrl:(NSString *)_url;
-(BOOL) newsCollectionDeleteDataWithId:(NSString*)_id;
-(void) newsCollectionDeleteAllData;
-(BOOL) newsCollectionIsExistCode:(NSString*)_id;
-(NSMutableArray*) newsCollectioSelectAll;

#pragma mark - Table OTCBeta NewsCollection
- (BOOL) otcbetaNewsCollectionInsertDataWithColumn:(NSString*)_column newsId:(NSString*)_newsId title:(NSString*)_title
                                       time:(NSString*)_time imageUrl:(NSString *)_url;
-(BOOL) otcbetaNewsCollectionDeleteDataWithId:(NSString*)_id;
-(void) otcbetaNewsCollectionDeleteAllData;
-(BOOL) otcbetaNewsCollectionIsExistCode:(NSString*)_id;
-(NSMutableArray*) otcbetaNewsCollectioSelectAll;

#pragma mark - Table NewsPaperCollection

- (BOOL) newsPaperCollectionInsertDataWithColumn:(NSString*)_column newsId:(NSString*)_newsId newsOid:(NSString *)_oid newsPid:(NSString *)_pid title:(NSString*)_title  time:(NSString*)_time imageUrl:(NSString *)_url;

-(BOOL) newsPaperCollectionDeleteDataWithId:(NSString*)_id oid:(NSString *)_oid;
-(void) newsPaperCollectionDeleteAllData;
-(BOOL) newsPaperCollectionIsExistCode:(NSString*)_id oid:(NSString *)_oid;
-(NSMutableArray*) newsPaperCollectioSelectAll;

#pragma mark - Table NewsPaperReading
- (BOOL) newsPaperReadInsertDataWithColumn:(NSString*)_column paperOid:(NSString*)_oid paperPid:(NSString*)_pid;
-(BOOL) newsPaperReadDeleteDataWithOid:(NSString*)_oid PaperPid:(NSString *)_pid;
-(void) newsPaperReadDeleteAllData;
-(BOOL) newsPaperReadIsExistOid:(NSString*)_oid PaperPid:(NSString *)_pid;
-(NSMutableArray*) newsPaperReadSelectAll;
-(int)newsPaperReadCount;


#pragma mark - Table AppAdvert
-(void) appAdvertInsertDataWithKindKind:(NSString*)_kind key:(NSString*)_key title:(NSString*)_title url:(NSString*)_url
                                   type:(NSString*)_type identify:(NSString *)_identify imageurl:(NSString*)_imageurl time:(NSString *)_time  v:(NSString *)_v;
-(void) appAdvertDeleteAllData;
-(NSDictionary*) appAdvertIsExistWithKey:(NSString*)_key;

+(AFDbManager*) dbManager;

@end
